package main

import "fmt"

type Sender interface {
	Send(to, msg string) error
	SendAll(tos []string, msg string) error
}

type SMSSender struct {
	url, key string
}

func NewSMSSender(url, key string) *SMSSender {
	return &SMSSender{url, key}
}

//接收者为指针对象
func (sender *SMSSender) Send(to, msg string) error {
	fmt.Printf("发送短信给: %s,内容: %s\n", to, msg)
	return nil
}

//接收者为指针对象
func (sender *SMSSender) SendAll(tos []string, msg string) error {
	for _, to := range tos {
		fmt.Printf("发送短信给: %s,内容: %s\n", to, msg)
	}
	return nil
}

func main() {
	//赋值sender对象为NewSMSSender指针对象
	var sender02 Sender = &SMSSender{
		url: "https://aa.com/sms/send",
		key: "1234",
	}
	fmt.Printf("%T: %v\n", sender02, sender02)
	sender02.Send("13661461543", "hi lwq")
	sender02.SendAll([]string{"13661461543", "13661488778"}, "good morning")

}
